$(function(){
	//城市下拉单
	$(".pull").click(function(){
        var index = $(".pull").index($(this));
		if($(".city").eq(index).is(":hidden")){
			$(".city").eq(index).slideDown();
//			index.$("span").css("background","url(../img/jianxia.png) no-repeat")
		}else{
			$(".city").eq(index).slideUp();
		}
	})
	//鼠标移上显示,移除隐藏
	$(".post").hover(function(){
		var index = $(".post").index($(this));
		$(".select").eq(index).css("display","block");
		$(".post").eq(index).css("background","#fff");
	},function(){
		$(".select").css("display","none");
		$(".post").css("background","#eee");
	})
	//鼠标选择城市，城市切换
	$(".select-top a,.select-down a").click(function(){
		var index = $(".select-top a,.select-down a").index($(this));
		$(".post>a").html($(".select-top a,.select-down a").eq(index).text());
	})
	//cookie获取
	var str = getCookie("order");
	if(str){
		var orderObj = JSON.parse(str);
		for(var i=0; i<orderObj.length; i++){
			var oImg = orderObj[i].oImg;
			var oName = orderObj[i].oName;
			var oHeft = orderObj[i].oHeft;
			var oPc=orderObj[i].oMoney;
			var oNum=orderObj[i].oNumInt;
			//console.log(oNum)
			$("#cart .cart-content .cart-order .cart-img img").attr("src",oImg);
			$("#cart .cart-content .cart-order .cart-name a").html(decodeURIComponent(oName));
			$("#cart .cart-content .cart-order .cart-heft span").html(oHeft);
			$("#cart .cart-content .cart-order .cart-money span").html(oPc);
			$("#cart .cart-content .cart-order .cart-jiajian .price-num-area .num-int").val(oNum);	
			var all=(oPc*oNum).toFixed(2);
            $("#cart .cart-content .cart-order .cart-moneyAll span").html(all);
//          $("cart-order").append($("cart-cart"));
            //$(".zongjia2").html(all);

		}
	}else{
		
	}
	//点击删除cookie
	$("#cart .cart-content .cart-order .cart-remove").click(function(){
		var index = $("#cart .cart-content .cart-order .cart-remove").index($(this));
		$("#cart .cart-content .cart-order .cart-cart").eq(index).css("display","none");
		$("#cart .cart-content .cart-order .nothing").css("display","block");
	})
	//数量加减
	$(".numup").click(function(){
		var i = $(".num-int").val();
		parseInt(i);
		i++;
		$(".num-int").val(i);
		var oPrice = Number($("#cart .cart-content .cart-order .cart-money span").html());
		var all=(oPrice*i).toFixed(2);
        $("#cart .cart-content .cart-order .cart-moneyAll span").html(all);		
	})
	$(".numdown").click(function(){
		var i = $(".num-int").val();
		parseInt(i);
		if(i<=1){
			i = 1; 
		}else{
			i--;
			$(".num-int").val(i);
			var oPrice = Number($("#cart .cart-content .cart-order .cart-money span").html());
			var all=(oPrice*i).toFixed(2);
	        $("#cart .cart-content .cart-order .cart-moneyAll span").html(all);			
		}
	})	

})